package com.jiajia.study.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: RabbitConfig
 * @Author zjj
 * @Package com.jiajia.study.config
 * @Date 2024/3/6 16:28
 * @description: rabbit 配置类
 */

@Configuration
public class RabbitConfig {
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("direct.exchange.a");
    }

    @Bean
    public Queue queueA(){
        return QueueBuilder.durable("direct.queue.a").build();
    }

    @Bean
    public Queue queueB(){
        return QueueBuilder.durable("direct.queue.b").build();
    }

    @Bean
    public Binding bindingA(DirectExchange directExchange,Queue queueA){
        return BindingBuilder.bind(queueA).to(directExchange).with("error");
    }

    @Bean
    public Binding bindingB1(DirectExchange directExchange,Queue queueB){
        return BindingBuilder.bind(queueB).to(directExchange).with("info");
    }

    @Bean
    public Binding bindingB2(DirectExchange directExchange,Queue queueB){
        return BindingBuilder.bind(queueB).to(directExchange).with("error");
    }

    @Bean
    public Binding bindingB3(DirectExchange directExchange,Queue queueB){
        return BindingBuilder.bind(queueB).to(directExchange).with("warning");
    }


}
